const Koa = require('koa');
const route = require('koa-route');
const compose = require('koa-compose');
const app = new Koa();

const err_handler = async (ctx,next) => {
    try {
        await next();
    } catch (err) {
        ctx.response.status = err.statusCode || err.status || 500;
        ctx.response.body = err.message;
    }
};

const e500_thrower = ctx =>{
    ctx.throw(500);
};
app.use(compose([err_handler,e500_thrower]));

app.listen(3006);
